package Theard;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class OvalThread extends JFrame{

	JButton bd = new JButton("Bất đầu"),
			td = new JButton("Tạm dừng"),
			tt = new JButton("Tiếp tục"),
			kt = new JButton("Kết thúc");
	JPanel ve = new JPanel();
	
	Thread Ov;
	
	public OvalThread(){
		setSize(400, 450);
		setVisible(true);
		
		add(ve, BorderLayout.CENTER);
		
		JPanel p = new JPanel();
		p.add(bd); p.add(td); p.add(tt); p.add(kt);
		add(p, BorderLayout.SOUTH);
		Ov = new Oval_Thread(ve);
		
		bd.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				Ov.start();
			}
		});
		
		td.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				Ov.suspend();
			}
		});

		tt.addActionListener(new ActionListener() {
	
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				Ov.resume();
			}
		});

		kt.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				Ov.stop();
				System.exit(0);
			}
		});
		
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new OvalThread();
	}

}
